/**
 * @description 选课列表
 */
import { post } from "@/util/request"
import { useStore } from "vuex";
const store = useStore()
const getClassList = async ({
    url = "/class-api/getClassList",
    params = Object,
    success = Function,
    error = Function,
    complete = Function,
}) => {
    try {
        const res = await post(url, {
            ...params
        })
        if (res.status === "0000") {
            success(res.data);
        } else {
            error(res)
        }

    } catch (error) {
        error(error)
    } finally {
        complete()
    }
}

const addClass = async ({
    url = String,
    params = Object,
    success = Function,
    error = Function,
    complete = Function,
}) => {
    try {
        const res = await post(url, {
            ...params
        })
        if (res.status === "0000") {
            success(res);
        } else {
            error(res)
            Dialog({
                title: "提示",
                message: res.message
              });
        }

    } catch (error) {
        error(error)
    } finally {
        complete()
    }
}

// 删除课程
const deleteClass = async ({
    url = "/class-api/deleteClass",
    params = Object,
    success = Function,
    error = Function,
    complete = Function,
}) => {
    try {
        const res = await post(url, {
            ...params
        })
        if (res.status === "0000") {
            success(res);
        } else {
            error(res)
        }

    } catch (error) {
        error(error)
    } finally {
        complete()
    }
}


export {
    getClassList, addClass, deleteClass
}